#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int n;
ll arr[maxn],sum,flag[maxn];
ll d;
bool cmp(int x,int y){
    return x>y;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    sort(arr+1,arr+1+n,cmp);
    ll ans=n;
    for(int i=1;i<=n;i++){
        if(arr[i]<=arr[n]){
                d=i;
                break;
        }
    }
    for(int i=n;i>=1;i--){
        if(sum<arr[i]+1){
            cout<<ans;
            return 0;
        }
        while(arr[d]<=arr[i]&&d>=1){
            d--;
        }
        if(d==0){
            cout<<ans;
            return 0;
        }
        ans--;
        d--;
    }
    cout<<ans;
    return 0;
}
